﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Faust.Andrew.MTG
{
    public partial class ReportPreviewForm : Form
    {
        private string _connectionString;
        private int _deckId;

        public ReportPreviewForm()
        {
            InitializeComponent();
        }

        public ReportPreviewForm(int deckId, string connectionString)
        {
            InitializeComponent();
            _deckId = deckId;
            _connectionString = connectionString;            
        }

        private void ReportPreviewForm_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(_connectionString)) { return; }

            // TODO: This line of code loads data into the 'DeckDataSet.Decks' table. You can move, or remove it, as needed.
            using (System.Data.SQLite.SQLiteConnection connection = new System.Data.SQLite.SQLiteConnection(_connectionString))
            {
                try
                {
                    DeckTableAdapter.Connection = connection;
                    DeckTableAdapter.Fill(DeckDataSet.Deck, _deckId);
                    report.RefreshReport();       
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                    throw;
                }
            }            
        }
    }
}
